﻿//////////////////////////////////////////////////////////////////////////////
//
//  Copyright © 1998-2024 Glodon Company Limited.  All rights reserved.
//
//  Use of this software is subject to the terms of the Glodon license
//  agreement provided at the time of installation or download, or which
//  otherwise accompanies this software in either electronic or hard copy form.  
//
//////////////////////////////////////////////////////////////////////////////

#pragma once
#include "GmFamilyService.h"
#include "IFamilyEntity.h"
#include "Vector3d.h"
namespace gcmp
{
    class IGraphicsBRepBody;
    class IVisibilityTypeFlags;
    class IGraphicsBRepEdge;
    class IGraphicsBRepFace;
    enum class GraphicsMaterialDisplayStyle;

}

namespace gfam
{
    class IFamilySketch2D;
    class IFamily2DSketchCurve;
    class IFamilySketchCurve;
    class RelationGraph;
    class IFamily2DSketchLine;
    
    /// \brief 几何实体基类
    class GM_FAMILY_SERVICE_EXPORT IFamilyForm : public IFamilyEntity
    {
        DEFINE_CAST_DERIVED(gfam::IFamilyForm, gfam::IFamilyEntity)

    public:

        /// \brief 获取body
        /// 
        /// \return body
        virtual const gcmp::IGraphicsBRepBody* GetGraphicsBRepBody() const = 0;

        /// \brief 设置body
        /// 
        /// \param body 设置的body
        virtual void SetGraphicsBRepBody(gcmp::OwnerPtr<gcmp::IGraphicsBRepBody> body) = 0;

        /// \brief 获取可见性标记
        /// 
        /// \return 可见性标记
        virtual const gcmp::IVisibilityTypeFlags* GetVisibilityTypeFlagsInHostDocument() const = 0;

        /// \brief 获取可见性标记
        /// 
        /// \return 可见性标记
        virtual gcmp::IVisibilityTypeFlags* GetVisibilityTypeFlagsInHostDocument() = 0;


        /// \brief 获取是否在项目可见
        /// 
        /// \return 项目可见
        virtual bool IsVisibleInHostDocument() const = 0;

        /// \brief 设置是否在项目可见
        /// 
        /// \param   isVisibleInHostDocument 项目可见性
        /// \return 设置成功返回true，否则返回false
        virtual bool SetVisibleInHostDocument(bool isVisibleInHostDocument) = 0;

        /// \brief 获取材质id
        /// 
        /// \return 材质id
        virtual gcmp::ElementId GetGraphicsMaterialId() const = 0;

        /// \brief 设置材质id
        /// 
        /// \param   materialId 材质id
        virtual void SetGraphicsMaterialId(const gcmp::ElementId& materialId) = 0;

        /// \brief 获取是否为扣减体
        /// 
        /// \return 如果是扣减体返回true,否则返回false
        virtual bool IsSubstraction() const = 0; 

        /// \brief 设置是否为扣减体
        /// 
        /// \param   isSubstraction 布尔标识
        /// \return 设置成功返回true，否则返回false
        virtual bool SetSubstraction(bool isSubstraction) = 0;

        /// \brief 获取材质显示方式
        /// 
        /// \return 材质显示方式
        virtual gcmp::GraphicsMaterialDisplayStyle GetGraphicsMaterialDisplayStyle() const = 0;

        /// \brief 设置材质显示方式
        /// 
        /// \param displayStyle     材质显示方式
        /// \return 设置成功返回true，否则返回false
        virtual bool SetGraphicsMaterialDisplayStyle(gcmp::GraphicsMaterialDisplayStyle displayStyle) = 0;

        /// \brief 获取图形相关参数关联更新Id
        /// 
        /// \return 图形相关参数关联更新Id
        virtual RegenDataId GetGRepRelatedParameterRdId() const = 0;

        /// \brief 获取项目可见关联更新Id
        /// 
        /// \return 项目可见关联更新Id
        virtual RegenDataId GetVisibleInHostDocumentParameterRdId() const = 0;

        /// \brief 获取材质参数关联更新Id
        /// 
        /// \return 项目材质参数关联更新Id
        virtual RegenDataId GetMaterialParameterRdId() const = 0;

        /// \brief 获取材质显示方式关联更新Id
        /// 
        /// \return 项目材质显示方式关联更新Id
        virtual RegenDataId GetMaterialDisplayStyleParameterRdId() const = 0;

        /// \brief 根据面索引获取面Id
        /// 
        /// \param faceIndex 面索引
        /// \return 面Id
        virtual gcmp::GraphicsNodeId GetFaceId(int faceIndex) const = 0;

        /// \brief 根据边索引获取边Id
        /// 
        /// \param edgeIndex 边索引
        /// \return 边Id
        virtual gcmp::GraphicsNodeId GetEdgeId(int edgeIndex) const = 0;

        /// \brief 根据面id获取面
        /// 
        /// \param faceId 面id
        /// \return 面指针
        virtual const gcmp::IGraphicsBRepFace* GetFace(gcmp::GraphicsNodeId faceId) const = 0;

        /// \brief 根据边id获取面
        /// 
        /// \param edgeId 边id
        /// \return 边指针
        virtual const gcmp::IGraphicsBRepEdge* GetEdge(gcmp::GraphicsNodeId edgeId) const = 0;

        /// \brief 检查草图数据是否合法
        /// 
        /// \return 合法返回true,否则返回false
        virtual bool CheckSketchDataIsValid() const = 0;

        /// \brief 检查草图数据是否合法
        /// 
        /// \param errorCurves 出现错误的草图线
        /// \return 合法返回true,否则返回false
        virtual bool CheckSketchDataIsValid(std::vector<IFamilySketchCurve*>& errorCurves) const = 0;

        
        /// \brief 向关系图中添加依赖（约束解算用）
        /// 
        /// \param graph 关系图
        virtual void AddDependencyToGraph(RelationGraph &graph) const = 0;

        /// \brief 获取图形引用所在的草图id
        /// 
        /// \param nodeReference 图形引用
        /// \return 草图id
        virtual gcmp::ElementId GetSketchOfOriginNodeReference(const gcmp::IGraphicsNodeReference& nodeReference) const = 0;

        /// \brief 获取所有轮廓草图id
        /// 
        /// \return 轮廓草图集合
        virtual std::vector<gcmp::ElementId> GetProfileSketchIds() const = 0;

        /// \brief 获取所有路径草图id
        /// 
        /// \return 路径草图集合
        virtual std::vector<gcmp::ElementId> GetPathSketchIds() const = 0;

        /// \brief 获取子类别id
        /// 
        /// \return 子类别id
        virtual gcmp::UniIdentity GetSubCategoryId() const = 0;
        /// \brief 设置子类别id
        /// 
        /// \param subCategoryId    子类别id
        virtual void SetSubCategoryId(const gcmp::UniIdentity& subCategoryId) = 0;

        /// \brief 获取几何体是否更新成功
        /// 
        /// \return 更新成功返回true,否则返回false
        virtual bool IsSuccessfullyUpdated() const = 0;

        /// \brief 获取布尔操作引用的几何体id
        /// 
        /// \return 几何体id集合
        virtual const std::vector<gcmp::ElementId>& GetCombinationIds() const = 0;

        /// \brief 添加父节点id
        /// 
        /// \param id 父节点id
        virtual void AddCombinationParentId(const gcmp::ElementId& id) = 0;

        /// \brief 获取需要旋转的面贴图表
        /// 
        /// \return 参数表，Key为图形节点标识符，value为需要旋转的角度（非弧度），顺时针为正，逆时针为负
        virtual const std::map<gcmp::GraphicsNodeId, double>& GetFaceTextureRotationMap() const = 0;

        /// \brief 设置需要旋转的面贴图表
        /// 
        /// \param faceTextureRotationMap Key为图形节点标识符，value为需要旋转的角度（非弧度），顺时针为正，逆时针为负
        /// \return void
        virtual void SetFaceTextureRotationMap(const std::map<gcmp::GraphicsNodeId, double> & faceTextureRotationMap) = 0;

        /// \brief 获取Implementation Uid
        ///
        /// \return UniIdentity 返回ImplementationUid
        static gcmp::UniIdentity GetImplementationUid();

    protected:

    };

} 
